/*
 * @Author: your name
 * @Date: 2021-10-02 19:50:59
 * @LastEditTime: 2021-10-02 20:18:41
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \luogu\1.6二分查找\P2249\main.cpp
 */
#include<iostream>

using namespace std;

const int NMAX = 1000010; //n的最大值
const int MMAX = 100010; //m的最大值

//该函数会默认找最左边的value index
int binarySearch(int n_array[],int left,int right,int value);
//默认找最右边的value index
int binarySearchRightIndex(int n_array[],int left,int right,int value);

int main(){
    int n,m;
    int n_array[NMAX],m_array[MMAX];
    //input
    cin >> n >> m;
    for(int i=1; i<=n; i++){
        cin >> n_array[i];
    }
    for(int i=1; i<=m; i++){
        cin >> m_array[i];
    }
    //find the first index and print
    for(int i=1; i<=m; i++){
        int index = binarySearch(n_array,1,n,m_array[i]);
        cout << index << " ";
    }
    return 0;
}

int binarySearch(int n_array[],int left,int right,int value)
{
    int l,r,m;
    l = left;
    r = right;
    while(l < r){
        //左开
        m = (l+r)/2;    
        if(value <= n_array[m]){
            r = m;
        }else{
            l = m+1;
        }
    }
    if(n_array[l] == value){
        return l;
    }
    return -1;
}

int binarySearchRightIndex(int n_array[],int left,int right,int value)
{
    int l,r,m;
    l = left;
    r = right;
    while(l < r){
        //右开
        m = (l+r+1)/2;    
        if(value < n_array[m]){
            r = m - 1;
        }else{
            l = m;
        }
    }
    if(n_array[l] == value){
        return l;
    }
    return -1;
}
